#include "BackgroundTest.h"
#include <iostream>

BackgroundTest::BackgroundTest() {
}
BackgroundTest::~BackgroundTest() {
}

void BackgroundTest::Initialize(sf::RenderWindow* window) {
	m_renderWindow = window;
	m_clock = new sf::Clock();
	m_test = 1;

	m_background1 = new sf::Texture();
	m_background1->loadFromFile("Assets/Images/Background/Background1.png");

		m_background2 = new sf::Texture();
	m_background2->loadFromFile("Assets/Images/Background/Background2.png");

		m_background3 = new sf::Texture();
	m_background3->loadFromFile("Assets/Images/Background/Background3.png");

		m_background4 = new sf::Texture();
	m_background4->loadFromFile("Assets/Images/Background/Background4.png");

		m_background5 = new sf::Texture();
	m_background5->loadFromFile("Assets/Images/Background/Background5.png");

		m_background6 = new sf::Texture();
	m_background6->loadFromFile("Assets/Images/Background/Background6.png");

		m_background7 = new sf::Texture();
	m_background7->loadFromFile("Assets/Images/Background/Background7.png");

		m_background8 = new sf::Texture();
	m_background8->loadFromFile("Assets/Images/Background/Background8.png");

	m_background9 = new sf::Texture();
	m_background9->loadFromFile("Assets/Images/Background/Background9.png");

	m_background10 = new sf::Texture();
	m_background10->loadFromFile("Assets/Images/Background/Background10.png");

	m_background11 = new sf::Texture();
	m_background11->loadFromFile("Assets/Images/Background/Background11.png");

		m_background12 = new sf::Texture();
	m_background12->loadFromFile("Assets/Images/Background/Background12.png");

		m_background13 = new sf::Texture();
	m_background13->loadFromFile("Assets/Images/Background/Background13.png");

		m_background14 = new sf::Texture();
	m_background14->loadFromFile("Assets/Images/Background/Background14.png");

		m_background15 = new sf::Texture();
	m_background15->loadFromFile("Assets/Images/Background/Background15.png");

		m_background16 = new sf::Texture();
	m_background16->loadFromFile("Assets/Images/Background/Background16.png");

		m_background17 = new sf::Texture();
	m_background17->loadFromFile("Assets/Images/Background/Background17.png");

		m_background18 = new sf::Texture();
	m_background18->loadFromFile("Assets/Images/Background/Background18.png");

	m_background19 = new sf::Texture();
	m_background19->loadFromFile("Assets/Images/Background/Background19.png");

	m_background20 = new sf::Texture();
	m_background20->loadFromFile("Assets/Images/Background/Background20.png");


	m_backgroundSprite = new sf::Sprite();
	m_backgroundSprite->setTexture(*m_background1);
	m_backgroundSprite->setPosition(-300,-100.f);
	m_backgroundSprite->scale(1.3f, 1.2f);

	m_texture1 = new sf::Texture();
	m_texture1->loadFromFile("Assets/Images/Waves/Wave1.png");
	
	m_texture2 = new sf::Texture();
	m_texture2->loadFromFile("Assets/Images/Waves/Wave2.png");
	
	m_texture3 = new sf::Texture();
	m_texture3->loadFromFile("Assets/Images/Waves/Wave3.png");
	
	m_texture4 = new sf::Texture();
	m_texture4->loadFromFile("Assets/Images/Waves/Wave4.png");
	
	m_texture5 = new sf::Texture();
	m_texture5->loadFromFile("Assets/Images/Waves/Wave5.png");
	
	m_texture6 = new sf::Texture();
	m_texture6->loadFromFile("Assets/Images/Waves/Wave6.png");
	
	m_texture7 = new sf::Texture();
	m_texture7->loadFromFile("Assets/Images/Waves/Wave7.png");
	
	m_texture8 = new sf::Texture();
	m_texture8->loadFromFile("Assets/Images/Waves/Wave8.png");
	
	m_texture9 = new sf::Texture();
	m_texture9->loadFromFile("Assets/Images/Waves/Wave9.png");
	
	m_texture10 = new sf::Texture();
	m_texture10->loadFromFile("Assets/Images/Waves/Wave10.png");
	
	m_texture11 = new sf::Texture();
	m_texture11->loadFromFile("Assets/Images/Waves/Wave11.png");

	m_texture12 = new sf::Texture();
	m_texture12->loadFromFile("Assets/Images/Waves/Wave12.png");

	m_texture13 = new sf::Texture();
	m_texture13->loadFromFile("Assets/Images/Waves/Wave13.png");

	m_texture14 = new sf::Texture();
	m_texture14->loadFromFile("Assets/Images/Waves/Wave14.png");

	m_texture15 = new sf::Texture();
	m_texture15->loadFromFile("Assets/Images/Waves/Wave15.png");

	m_texture16 = new sf::Texture();
	m_texture16->loadFromFile("Assets/Images/Waves/Wave16.png");

	m_texture17 = new sf::Texture();
	m_texture17->loadFromFile("Assets/Images/Waves/Wave17.png");

	m_texture18 = new sf::Texture();
	m_texture18->loadFromFile("Assets/Images/Waves/Wave18.png");

	m_texture19 = new sf::Texture();
	m_texture19->loadFromFile("Assets/Images/Waves/Wave19.png");

	m_texture21 = new sf::Texture();
	m_texture21->loadFromFile("Assets/Images/Waves/Wave21.png");

	m_texture22 = new sf::Texture();
	m_texture22->loadFromFile("Assets/Images/Waves/Wave22.png");

	m_texture23 = new sf::Texture();
	m_texture23->loadFromFile("Assets/Images/Waves/Wave23.png");

	m_texture24 = new sf::Texture();
	m_texture24->loadFromFile("Assets/Images/Waves/Wave24.png");

	m_texture25 = new sf::Texture();
	m_texture25->loadFromFile("Assets/Images/Waves/Wave25.png");

	m_texture26 = new sf::Texture();
	m_texture26->loadFromFile("Assets/Images/Waves/Wave26.png");

	m_texture27 = new sf::Texture();
	m_texture27->loadFromFile("Assets/Images/Waves/Wave27.png");

	m_texture28 = new sf::Texture();
	m_texture28->loadFromFile("Assets/Images/Waves/Wave28.png");

	m_texture29 = new sf::Texture();
	m_texture29->loadFromFile("Assets/Images/Waves/Wave29.png");

	m_texture30 = new sf::Texture();
	m_texture30->loadFromFile("Assets/Images/Waves/Wave30.png");

	m_texture31 = new sf::Texture();
	m_texture31->loadFromFile("Assets/Images/Waves/Wave31.png");

	m_texture32 = new sf::Texture();
	m_texture32->loadFromFile("Assets/Images/Waves/Wave32.png");

	m_texture33 = new sf::Texture();
	m_texture33->loadFromFile("Assets/Images/Waves/Wave33.png");

	m_texture34 = new sf::Texture();
	m_texture34->loadFromFile("Assets/Images/Waves/Wave34.png");

	m_texture35 = new sf::Texture();
	m_texture35->loadFromFile("Assets/Images/Waves/Wave35.png");

	m_texture36 = new sf::Texture();
	m_texture36->loadFromFile("Assets/Images/Waves/Wave36.png");

	m_texture37 = new sf::Texture();
	m_texture37->loadFromFile("Assets/Images/Waves/Wave37.png");

	m_texture38 = new sf::Texture();
	m_texture38->loadFromFile("Assets/Images/Waves/Wave38.png");

	m_texture39 = new sf::Texture();
	m_texture39->loadFromFile("Assets/Images/Waves/Wave39.png");

	m_texture20 = new sf::Texture();
	m_texture20->loadFromFile("Assets/Images/Waves/Wave20.png");
	
	m_sprite1 = new sf::Sprite();
	m_sprite1->setTexture(*m_texture1);

	m_sprite1->setPosition(-300,0.f);
	m_sprite1->scale(1.3f, 1.f);

	m_test2 = 1;
	m_timer = 0.f;
	m_timer2 = 0.f;
}

void BackgroundTest::Update() {
	m_deltaTime = m_clock->restart().asSeconds();
	m_timer += m_deltaTime;		
	m_timer2 += m_deltaTime;
	
	if(m_test2 == 1){
		m_backgroundSprite->setTexture(*m_background1);
	}else if(m_test2 == 2){
		m_backgroundSprite->setTexture(*m_background2);
	}else if(m_test2 == 3){
		m_backgroundSprite->setTexture(*m_background3);
	}else if(m_test2 == 4){
		m_backgroundSprite->setTexture(*m_background4);
	}else if(m_test2 == 5){
		m_backgroundSprite->setTexture(*m_background5);
	}else if(m_test2 == 6){
		m_backgroundSprite->setTexture(*m_background6);
	}else if(m_test2 == 7){
		m_backgroundSprite->setTexture(*m_background7);
	}else if(m_test2 == 8){
		m_backgroundSprite->setTexture(*m_background8);
	}else if(m_test2 == 9){
		m_backgroundSprite->setTexture(*m_background9);
	}else if(m_test2 == 10){
		m_backgroundSprite->setTexture(*m_background10);
	}else if(m_test2 == 11){
		m_backgroundSprite->setTexture(*m_background11);
	}else if(m_test2 == 12){
		m_backgroundSprite->setTexture(*m_background12);
	}else if(m_test2 == 13){
		m_backgroundSprite->setTexture(*m_background13);
	}else if(m_test2 == 14){
		m_backgroundSprite->setTexture(*m_background14);
	}else if(m_test2 == 15){
		m_backgroundSprite->setTexture(*m_background15);
	}else if(m_test2 == 16){
		m_backgroundSprite->setTexture(*m_background16);
	}else if(m_test2 == 17){
		m_backgroundSprite->setTexture(*m_background17);
	}else if(m_test2 == 18){
		m_backgroundSprite->setTexture(*m_background18);
	}else if(m_test2 == 19){
		m_backgroundSprite->setTexture(*m_background19);
	}else if(m_test2 == 20){
		m_backgroundSprite->setTexture(*m_background20);
		m_test2 = 1;
	}

	m_renderWindow->draw(*m_backgroundSprite);

	if(m_test == 1){
		m_sprite1->setTexture(*m_texture1);
	}else if(m_test == 2){
		m_sprite1->setTexture(*m_texture2);
	}else if(m_test == 3){
		m_sprite1->setTexture(*m_texture3);
	}else if(m_test == 4){
		m_sprite1->setTexture(*m_texture4);
	}else if(m_test == 5){
		m_sprite1->setTexture(*m_texture5);
	}else if(m_test == 6){
		m_sprite1->setTexture(*m_texture6);
	}else if(m_test == 7){
		m_sprite1->setTexture(*m_texture7);
	}else if(m_test == 8){
		m_sprite1->setTexture(*m_texture8);
	}else if(m_test == 9){
		m_sprite1->setTexture(*m_texture9);
	}else if(m_test == 10){
		m_sprite1->setTexture(*m_texture10);
	}else if(m_test == 11){
		m_sprite1->setTexture(*m_texture11);
	}else if(m_test == 12){
		m_sprite1->setTexture(*m_texture12);
	}else if(m_test == 13){
		m_sprite1->setTexture(*m_texture13);
	}else if(m_test == 14){
		m_sprite1->setTexture(*m_texture14);
	}else if(m_test == 15){
		m_sprite1->setTexture(*m_texture15);
	}else if(m_test == 16){
		m_sprite1->setTexture(*m_texture16);
	}else if(m_test == 17){
		m_sprite1->setTexture(*m_texture17);
	}else if(m_test == 18){
		m_sprite1->setTexture(*m_texture18);
	}else if(m_test == 19){
		m_sprite1->setTexture(*m_texture19);
	}else if(m_test == 20){
		m_sprite1->setTexture(*m_texture20);
	}else if(m_test == 21){
		m_sprite1->setTexture(*m_texture21);
	}else if(m_test == 22){
		m_sprite1->setTexture(*m_texture22);
	}else if(m_test == 23){
		m_sprite1->setTexture(*m_texture23);
	}else if(m_test == 24){
		m_sprite1->setTexture(*m_texture24);
	}else if(m_test == 25){
		m_sprite1->setTexture(*m_texture25);
	}else if(m_test == 26){
		m_sprite1->setTexture(*m_texture26);
	}else if(m_test == 27){
		m_sprite1->setTexture(*m_texture27);
	}else if(m_test == 28){
		m_sprite1->setTexture(*m_texture28);
	}else if(m_test == 29){
		m_sprite1->setTexture(*m_texture29);
	}else if(m_test == 30){
		m_sprite1->setTexture(*m_texture30);
	}else if(m_test == 31){
		m_sprite1->setTexture(*m_texture31);
	}else if(m_test == 32){
		m_sprite1->setTexture(*m_texture32);
	}else if(m_test == 33){
		m_sprite1->setTexture(*m_texture33);
	}else if(m_test == 34){
		m_sprite1->setTexture(*m_texture34);
	}else if(m_test == 35){
		m_sprite1->setTexture(*m_texture35);
	}else if(m_test == 36){
		m_sprite1->setTexture(*m_texture36);
	}else if(m_test == 37){
		m_sprite1->setTexture(*m_texture37);
	}else if(m_test == 38){
		m_sprite1->setTexture(*m_texture38);	
	}else if(m_test == 39){
		m_sprite1->setTexture(*m_texture39);
		m_test = 1;
	}
		
	m_renderWindow->draw(*m_sprite1);

		//m_test = 1;

	if(m_timer > 0.02f){
		m_test++;
		m_timer = 0.f;
	}

	if(m_timer2 > 0.04f){
		m_test2++;
		m_timer2 = 0.f;
	}
	
}

void BackgroundTest::Render() {

}

void BackgroundTest::Cleanup() {
	delete		m_texture1;
	delete		m_texture2;
	delete		m_texture3;
	delete		m_texture4;
	delete		m_texture5;
	delete	m_texture6;
	delete		m_texture7;
	delete		m_texture8;
	delete		m_texture9;
	delete		m_texture10;
	delete		m_texture11;
	delete		m_texture12;
	delete		m_texture13;
	delete	m_texture14;
	delete		m_texture15;
	delete		m_texture16;
	delete		m_texture17;
	delete		m_texture18;
	delete		m_texture19;
	delete		m_texture21;
	delete		m_texture22;
	delete		m_texture23;
	delete		m_texture24;
	delete		m_texture25;
	delete		m_texture26;
	delete		m_texture27;
	delete		m_texture28;
	delete		m_texture29;
	delete		m_texture30;
	delete		m_texture31;
	delete		m_texture32;
	delete		m_texture33;
	delete		m_texture34;
	delete		m_texture35;
	delete		m_texture36;
	delete		m_texture37;
	delete		m_texture38;
	delete		m_texture39;
	delete		m_texture20;

	delete		m_sprite1;

	delete m_backgroundSprite; 
	delete m_background1; 
	delete m_background2; 
	delete m_background3; 
	delete m_background4; 
	delete m_background5; 
	delete m_background6; 
	delete m_background7; 
	delete m_background8; 
	delete m_background9; 
	delete m_background10; 
	delete m_background11; 
	delete m_background12; 
	delete m_background13; 
	delete m_background14; 
	delete m_background15; 
	delete m_background16; 
	delete m_background17; 
	delete m_background18; 
	delete m_background19; 
	delete m_background20; 




}